package com.dycx.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.*;

/**
 * 业务类型
 */
@Getter
@AllArgsConstructor
public enum BizTypeEnum {
    NO(0, "无"),

    USER_ACCOUNT(1, "会员"),
    USER_SELLER(2, "商家"),
    USER_INDUSTRY_TYPE(3, "行业分类"),
    SYS_ADMIN(4, "后台用户"),
    SYS_CONFIG(5, "系统配置"),
    SYS_ROLE(6, "系统角色"),
    SYS_PERMISSION(30, "系统权限"),
    MALL_BRAND(7, "商品品牌"),
    MALL_DESIGN(8, "商品系列"),
    MALL_EXPRESS(9, "快递公司"),
    MALL_GOODS(10, "商品"),
    MALL_GOODS_CLASS(11, "商品分类"),
    MALL_GOODS_TYPE(12, "商品类型"),
    MALL_ORDER(13, "商品订单"),
    MALL_SPEC(14, "商品规格"),
    MALL_RECOMMEND_TYPE(150, "商品推荐"),
    CMS_AD(16, "广告"),
    CMS_AD_TYPE(17, "广告分类"),
    CMS_ARTICLE(18, "文章"),
    CMS_ARTICLE_TYPE(19, "文章类型"),
    CMS_LINK(20, "友情链接"),
    SYS_REGION(21, "地区"),
    JOB_TYPE(22, "职位类型"),
    JOB(24, "招聘"),
    RESUME(25, "简历"),
    SERVICE_INFO(26, "服务"),
    PAY(27, "支付业务"),
    INTERCITY_ARRANGE(28, "班次"),
    INTERCITY_TICKET_ORDER(29, "车票订单");

    private final Integer code;
    private final String name;

    public static String converter(Integer code) {
        return Arrays.stream(values()).filter(en -> en.code.equals(code)).findAny().orElse(NO).getName();
    }

    /**
     * 转为列表
     *
     * @return 枚举对象数组
     */
    public static List<Map<String, Object>> getList() {
        List<Map<String, Object>> list = new ArrayList<>();
        for (BizTypeEnum item : BizTypeEnum.values()) {
            Map<String, Object> map = new HashMap<>();
            map.put("code", item.getCode().toString());
            map.put("name", item.getName());
            list.add(map);
        }
        return list;
    }

}
